﻿@model ArticleEditDto
@Html.Extra()
@{
Layout = "~/Views/Shared/OA/_Form.cshtml";

var catalog = (Catalog)ViewBag.Catalog;
var config = SerializationHelper.JsonDeserialize<JObject>(catalog.Config);
    var create = ViewContext.RouteData.Values["Action"].ToString() == "Create";
    //是否返回当前页面
    var isBackThis = Request["back"] == "thisBack";
    var qphId = ConvertHelper.ToGuid(Request["qphId"]);
    var qph = IoCHeler.Resolve<IArticleAppService>().GetArticle(qphId);
        if (isBackThis)
        {
        AssertHelper.NoPass(qph == null, "未找到汽派号");
        }
        }
        @section Toolbar
        {

        @if (isBackThis)
        {
        <button class="k-button" onclick="save()"><span class="i i-save"></span>保存</button>
        <button class="k-button" onclick="backThis()"><span class="i i-backThis"></span>返回</button>
        }
        else
        {
        @Html.MyNet().Button(new ButtonOptions { Text = "保存", Click = "save" })
        @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
        }
        }
        @section Main
        {
        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.Key)
        @Html.HiddenFor(model => model.ObjectId)
        @Html.HiddenFor(model => model.CatalogIds)


        <table width="97%">
            <col width="110px" />
            <tr>
                <th>
                    ID
                </th>
                <td>
                    @Model.Id
                </td>
            </tr>
            <tr>
                <th>
                    文章Key
                </th>
                <td>
                    @Model.Key
                </td>
            </tr>
            @if (config.GetBoolean("Catalog_EditVisible"))
            {
            <tr>
                <th>
                    <b>*</b>@Html.LabelFor(model => model.CatalogId, "栏目")
                </th>
                <td>
                    @Html.MyNet().DropDownTreeFor(model => model.CatalogId, Url.Action("ReadForParent", "Catalog", new { ParentKey = "Article" }), "请选择栏目", new ValidateOptions
                    {
                    RequiredError = "请选择栏目"
                    }, null, "onSelect")
                    @Html.MyNet().ValidationMessageFor(model => model.CatalogId)
                    <script>
                      function onSelect(value) {
                        location = "/CMS/Article/Create?CatalogId=" + value;
                      }
                    </script>
                </td>
            </tr>
            }
            else
            {
            @Html.HiddenFor(model => model.CatalogId)
            }
            @if (config.GetBoolean("Receipt_EditVisible"))
            {
            <tr>
                <th>
                    @Html.LabelFor(model => model.Receiptants, "接收人")
                </th>
                <td>
                    @Html.MyNet().HumanPickerFor(model => model.Receiptants)
                    (为空时代表全体员工)
                    @if (create)
                    {
                    Model.IsNotify = config.GetBoolean("Receipt_IsNotify");
                    }
                    @Html.CheckBoxFor(model => model.IsNotify)
                    @Html.LabelFor(model => model.IsNotify, "是否通知接收人")
                </td>
            </tr>
            }
            @{
            if (create)
            {
            Model.Title = config.GetString("Title_Value");
            }
            var title_Display = string.IsNullOrEmpty(config.GetString("Title_Display")) ? "标题" : config.GetString("Title_Display");
            <tr>
                <th>
                    <b>*</b>@Html.LabelFor(model => model.Title, title_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Title, new ValidateOptions
                    {
                    RequiredError = "请输入" + title_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Title)
                </td>
            </tr>
            }
            @if (config.GetBoolean("FullTitle_EditVisible"))
            {
            if (create)
            {
            Model.FullTitle = config.GetString("FullTitle_Value");
            }
            var FullTitle_Display = string.IsNullOrEmpty(config.GetString("FullTitle_Display")) ? "完整标题" : config.GetString("FullTitle_Display");
            var FullTitle_Required = config.GetBoolean("FullTitle_Required");
            <tr>
                <th>
                    @if (FullTitle_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.FullTitle, FullTitle_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.FullTitle, !FullTitle_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + FullTitle_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.FullTitle)
                </td>
            </tr>
            }
            @if (config.GetBoolean("SubTitle_EditVisible"))
            {
            if (create)
            {
            Model.SubTitle = config.GetString("SubTitle_Value");
            }
            var SubTitle_Display = string.IsNullOrEmpty(config.GetString("SubTitle_Display")) ? "子标题" : config.GetString("SubTitle_Display");
            var SubTitle_Required = config.GetBoolean("SubTitle_Required");
            <tr>
                <th>
                    @if (SubTitle_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.SubTitle, SubTitle_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.SubTitle, !SubTitle_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + SubTitle_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.SubTitle)
                </td>
            </tr>
            }
            @if (config.GetBoolean("TitleStyle_EditVisible"))
            {
            if (create)
            {
            Model.TitleStyle = config.GetString("TitleStyle_Value");
            }
            <tr>
                <th>
                    @Html.LabelFor(model => model.TitleStyle, string.IsNullOrEmpty(config.GetString("TitleStyle_Display")) ?
                    "标题样式" :
                    config.GetString("TitleStyle_Display"))
                </th>
                <td class="checkbox titleStyle">
                    @Html.HiddenFor(model => model.TitleStyle)
                    <input id="bold" type="checkbox" />
                    <label for="bold">
                        加粗
                    </label>
                    <input id="red" type="checkbox" />
                    <label for="red">
                        加红
                    </label>
                    <input id="italic" type="checkbox" />
                    <label for="italic">
                        斜体
                    </label>
                    <input id="underline" type="checkbox" />
                    <label for="underline">
                        下划线
                    </label>
                    <script>
                      jQuery(function myfunction() {
                        var style = $("#TitleStyle").val().toLowerCase();
                        $("#bold")[0].checked = style.indexOf("bold") > 0;
                        $("#red")[0].checked = style.indexOf("red") > 0;
                        $("#italic")[0].checked = style.indexOf("italic") > 0;
                        $("#underline")[0].checked = style.indexOf("underline") > 0;

                        $(".titleStyle :checkbox").click(function myfunction() {
                          style = "";
                          if ($("#bold")[0].checked)
                            style += "font-weight: bold; ";
                          if ($("#red")[0].checked)
                            style += "color: red; ";
                          if ($("#italic")[0].checked)
                            style += "font-style: italic; ";
                          if ($("#underline")[0].checked)
                            style += "text-decoration: underline; ";

                          $("#TitleStyle").val(style);
                        });
                      });
                    </script>
                </td>
            </tr>
            }
            @if (config.GetBoolean("Keyword_EditVisible"))
            {
            if (create)
            {
            Model.Keyword = config.GetString("Keyword_Value");
            }
            var Keyword_Display = string.IsNullOrEmpty(config.GetString("Keyword_Display")) ? "关键字" : config.GetString("Keyword_Display");
            var Keyword_Required = config.GetBoolean("Keyword_Required");
            <tr>
                <th>
                    @if (Keyword_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.Keyword, Keyword_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Keyword, !Keyword_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + Keyword_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Keyword)
                </td>
            </tr>
            }
            @if (config.GetBoolean("Tag_EditVisible"))
            {
            if (create)
            {
            Model.Tag = config.GetString("Tag_Value");
            }
            var Tag_Display = string.IsNullOrEmpty(config.GetString("Tag_Display")) ? "标签" : config.GetString("Tag_Display");
            var Tag_Required = config.GetBoolean("Tag_Required");
            <tr>
                <th>
                    @if (Tag_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.Tag, Tag_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Tag, !Tag_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + Tag_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Tag)
                </td>
            </tr>
            }
            @if (config.GetBoolean("Origin_EditVisible"))
            {
            if (create)
            {
            Model.Origin = config.GetString("Origin_Value");
            }
            var Origin_Display = string.IsNullOrEmpty(config.GetString("Origin_Display")) ? "来源" : config.GetString("Origin_Display");
            var Origin_Required = config.GetBoolean("Origin_Required");
            <tr>
                <th>
                    @if (Origin_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.Origin, Origin_Display)
                </th>
                <td>
                    @if (catalog.IsQPH)
                    {
                    if (isBackThis)
                    {
                    @Html.Hidden("Origin", qph.Id)
                    @qph.Title
                    }
                    else
                    {
                    @Html.MyNet().DropDownListFor(model => model.Origin, "/cms/article/ReadForQPH?catalogKey=qphgl", "id", "text", "请选择" + Origin_Display, !Origin_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请选择" + Origin_Display,
                    LengthMax = 256
                    })
                    }

                    @Html.MyNet().ValidationMessageFor(model => model.Origin)
                    }
                    else
                    {
                    @Html.MyNet().TextBoxFor(model => model.Origin, !Origin_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + Origin_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Origin)
                    }
                </td>
            </tr>
            }
            @if (config.GetBoolean("Author_EditVisible"))
            {
            if (create)
            {
            Model.Author = config.GetString("Author_Value");
            }
            var Author_Display = string.IsNullOrEmpty(config.GetString("Author_Display")) ? "作者" : config.GetString("Author_Display");
            var Author_Required = config.GetBoolean("Author_Required");
            <tr>
                <th>
                    @if (Author_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.Author, Author_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.Author, !Author_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + Author_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Author)
                </td>
            </tr>
            }

            @if (config.GetBoolean("TransferUrl_EditVisible"))
            {
            if (create)
            {
            Model.TransferUrl = config.GetString("TransferUrl_Value");
            }
            var TransferUrl_Display = string.IsNullOrEmpty(config.GetString("TransferUrl_Display")) ? "转向链接" : config.GetString("TransferUrl_Display");
            var TransferUrl_Required = config.GetBoolean("TransferUrl_Required");
            <tr>
                <th>
                    @if (TransferUrl_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.TransferUrl, TransferUrl_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.TransferUrl, !TransferUrl_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + TransferUrl_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.TransferUrl)
                </td>
            </tr>
            }
            @if (config.GetBoolean("TitleImage_EditVisible"))
            {
            var TitleImage_Display = string.IsNullOrEmpty(config.GetString("TitleImage_Display")) ? "标题图片" : config.GetString("TitleImage_Display");
            var TitleImage_Required = config.GetBoolean("TitleImage_Required");
            <tr>
                <th>
                    @if (TitleImage_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.TitleImageUrl, TitleImage_Display)
                </th>
                <td>
                    @Html.MyNet().UploadFor(model => model.TitleImageUrl, new UploadOptions
                    {
                    AttachmentKey = Model.Id,
                    AttachmentTypeKey = "CMS_ArticleTitleImage",
                    UploadMode = UploadMode.ImageSingle,
                    ImageWidth = config.GetIntNullable("TitleImage_Width"),
                    ImageHeight = config.GetIntNullable("TitleImage_Height"),
                    PreviewImageWidth = config.GetIntNullable("TitleImage_PreviewWidth"),
                    PreviewImageHeight = config.GetIntNullable("TitleImage_PreviewHeight"),
                    }, !TitleImage_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请上传" + TitleImage_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.TitleImageUrl)
                </td>
            </tr>
            }
            @if (config.GetBoolean("ImageUrl_EditVisible"))
            {
            var ImageUrl_Display = string.IsNullOrEmpty(config.GetString("ImageUrl_Display")) ? "图片" : config.GetString("ImageUrl_Display");
            var ImageUrl_Required = config.GetBoolean("ImageUrl_Required");
            <tr>
                <th>
                    @if (ImageUrl_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.ImageUrl, ImageUrl_Display)
                </th>
                <td>
                    @Html.MyNet().UploadFor(model => model.ImageUrl, new UploadOptions
                    {
                    AttachmentKey = Model.Id,
                    AttachmentTypeKey = "CMS_ArticleImage",
                    UploadMode = UploadMode.ImageSingle,
                    ImageWidth = config.GetIntNullable("ImageUrl_Width"),
                    ImageHeight = config.GetIntNullable("ImageUrl_Height"),
                    PreviewImageWidth = config.GetIntNullable("ImageUrl_PreviewWidth"),
                    PreviewImageHeight = config.GetIntNullable("ImageUrl_PreviewHeight"),
                    }, !ImageUrl_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请上传" + ImageUrl_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ImageUrl)
                </td>
            </tr>
            }
            @if (config.GetBoolean("Image_EditVisible"))
            {
            var Image_Display = string.IsNullOrEmpty(config.GetString("Image_Display")) ? "图片" : config.GetString("Image_Display");
            var Image_Required = config.GetBoolean("Image_Required");
            <tr>
                <th>
                    @if (Image_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.ImageUrl, Image_Display)
                </th>
                <td>
                    @Html.MyNet().UploadFor(model => model.ImageUrl, new UploadOptions
                    {
                    AttachmentKey = Model.Id,
                    AttachmentTypeKey = "CMS_ArticleImage",
                    UploadMode = UploadMode.ImageMulti,
                    ImageWidth = config.GetIntNullable("Image_Width"),
                    ImageHeight = config.GetIntNullable("Image_Height"),
                    PreviewImageWidth = config.GetIntNullable("Image_PreviewWidth"),
                    PreviewImageHeight = config.GetIntNullable("Image_PreviewHeight"),
                    }, !Image_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请上传" + Image_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ImageUrl)
                </td>
            </tr>
            }
            @if (config.GetBoolean("Video_EditVisible"))
            {
            var Video_Display = string.IsNullOrEmpty(config.GetString("Video_Display")) ? "视频" : config.GetString("Video_Display");
            var Video_Required = config.GetBoolean("Video_Required");
            <tr>
                <th>
                    @if (Video_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.Video, Video_Display)
                </th>
                <td>
                    @*@Html.MyNet().UploadFor(model => model.Video, new UploadOptions
                    {
                    AttachmentKey = Model.Id,
                    AttachmentTypeKey = "Video_AttachmentType",
                    UploadMode = UploadMode.FileSingle
                    }, !Video_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请上传" + Video_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Video)*@
                    <input data-val="true" data-val-required="请上传视频" id="Video" name="Video" style="display:none;" type="text" value="@Model.Video">
                    <input type="file" id="uploadify_mpb1eb1a45ogbbvi">
                    <script>
                      jQuery(function () {
                        var remove = function (element) {
                          $(element).parent().remove();
                          $('#Video').val('');

                          //删除文件
                        };

                        var bind = function (fileUrl) {
                          if (!fileUrl &&'@Model.Video' != "") {
                            fileUrl= '@Model.Video';
                          }

                          if (fileUrl) {
                            $("#links_mpb1eb1a45ogbbvi").html('<span><a target="_blank" href='+fileUrl + '>文件</a><i>×</i></span>');

                            $('#Video').val(fileUrl);
                            $("#links_mpb1eb1a45ogbbvi i").unbind("click");
                            $("#links_mpb1eb1a45ogbbvi i").bind("click", function () {
                              remove(this);
                            });
                          }
                        };

                        $("#uploadify_mpb1eb1a45ogbbvi").uploadify(
                          {
                            auto: true,
                            multi: false,
                            width: 360,
                            height: 26,
                            buttonText: "选择文件",
                            swf: "/App_Content/Plugin/uploadify/uploadify.swf",
                            uploader: "/CMS/Commons/UploadFile",
                            fileTypeDesc: "文件",
                            fileTypeExts: "*.mp4",//*.mp4;*.b
                            fileSizeLimit: 1024*80,//限制上传大小80M
                            successTimeout:60,//默认30秒，超过时间中断
                            onUploadSuccess: function (file, result, response) {
                              if (disposeException(result)) return;
                              bind(JSON.parse(result).Url);

                            }
                          });

                        bind();
                      });
                    </script>
                    <div id="links_mpb1eb1a45ogbbvi" class="uploadify-links"></div>

                    <span class="field-validation-valid" data-valmsg-for="Video" data-valmsg-replace="true"></span>
                </td>
            </tr>
            }
            @if (config.GetBoolean("Topic_EditVisible"))
            {
            var Topic_Display = string.IsNullOrEmpty(config.GetString("Topic_Display")) ? "专题包附件" : config.GetString("Topic_Display");
            var Topic_Required = config.GetBoolean("Topic_Required");
            <tr>
                <th>
                    @if (Topic_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.TopicDecompressUrl, Topic_Display)
                </th>
                <td>
                    @Html.MyNet().UploadFor(model => model.TopicDecompressUrl, new UploadOptions
                    {
                    AttachmentKey = Model.Id,
                    AttachmentTypeKey = "CMS_ArticleTopic",
                    UploadMode = UploadMode.FileSingle
                    }, !Topic_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请上传" + Topic_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.TopicDecompressUrl)
                </td>
            </tr>
            }
            @if (config.GetBoolean("City_EditVisible"))
            {
            if (create)
            {
            Model.City = config.GetIntNullable("City_Value");
            }
            var City_Display = string.IsNullOrEmpty(config.GetString("City_Display")) ? "城市" : config.GetString("Topic_Display");
            var City_Required = config.GetBoolean("City_Required");
            <tr>
                <th>
                    @if (City_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.City, City_Display)
                </th>
                <td>
                    @Html.MyNet().DropDownEnumListFor(model => model.City, "CMS_City", "请选择" + City_Display, !City_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + City_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.City)
                </td>
            </tr>
            }
            @if (config.GetBoolean("PublishTime_EditVisible"))
            {
            if (create)
            {
            Model.PublishTime = config.GetDateTimeNullable("PublishTime_Value");
            }
            var PublishTime_Display = string.IsNullOrEmpty(config.GetString("PublishTime_Display")) ? "发布时间" : config.GetString("PublishTime_Display");
            var PublishTime_Required = config.GetBoolean("PublishTime_Required");
            <tr>
                <th>
                    @if (PublishTime_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.PublishTime, PublishTime_Display)
                </th>
                <td>
                    @Html.MyNet().DateTimePickerFor(model => model.PublishTime, new DateTimeOptions { DefaultNow = true }, !PublishTime_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + PublishTime_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.PublishTime)
                </td>
            </tr>
            }
            @if (config.GetBoolean("ViewCount_EditVisible"))
            {
            if (create)
            {
            Model.ViewCount = config.GetInt("ViewCount_Value");
            }
            var ViewCount_Display = string.IsNullOrEmpty(config.GetString("ViewCount_Display")) ? "查看数" : config.GetString("ViewCount_Display");
            var ViewCount_Required = config.GetBoolean("ViewCount_Required");
            <tr>
                <th>
                    @if (ViewCount_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.ViewCount, ViewCount_Display, !ViewCount_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + ViewCount_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.ViewCount)
                    @Html.MyNet().ValidationMessageFor(model => model.ViewCount)
                </td>
            </tr>
            }
            @if (config.GetBoolean("CycleAddViewCount_EditVisible"))
            {
            if (create)
            {
            Model.CycleAddViewCount = config.GetInt("CycleAddViewCount_Value");
            }
            var CycleAddViewCount_Display = string.IsNullOrEmpty(config.GetString("CycleAddViewCount_Display")) ? "每小时自动新增阅读数" : config.GetString("CycleAddViewCount_Display");
            var CycleAddViewCount_Required = config.GetBoolean("CycleAddViewCount_Required");
            <tr>
                <th>
                    @if (CycleAddViewCount_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.CycleAddViewCount, CycleAddViewCount_Display, !CycleAddViewCount_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + CycleAddViewCount_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.CycleAddViewCount) (每次随机 + -10)
                    @Html.MyNet().ValidationMessageFor(model => model.CycleAddViewCount)
                </td>
            </tr>
            }
            @if (config.GetBoolean("LikeCount_EditVisible"))
            {
            if (create)
            {
            Model.LikeCount = config.GetInt("LikeCount_Value");
            }
            var LikeCount_Display = string.IsNullOrEmpty(config.GetString("LikeCount_Display")) ? "点赞数" : config.GetString("LikeCount_Display");
            var LikeCount_Required = config.GetBoolean("LikeCount_Required");
            <tr>
                <th>
                    @if (LikeCount_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.LikeCount, LikeCount_Display, !LikeCount_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + LikeCount_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.LikeCount)
                    @Html.MyNet().ValidationMessageFor(model => model.LikeCount)
                </td>
            </tr>
            }
            @if (config.GetBoolean("CycleAddLikeCount_EditVisible"))
            {
            if (create)
            {
            Model.CycleAddLikeCount = config.GetInt("CycleAddLikeCount_Value");
            }
            var CycleAddLikeCount_Display = string.IsNullOrEmpty(config.GetString("CycleAddLikeCount_Display")) ? "每小时自动新增点赞数" : config.GetString("CycleAddLikeCount_Display");
            var CycleAddLikeCount_Required = config.GetBoolean("CycleAddLikeCount_Required");
            <tr>
                <th>
                    @if (CycleAddLikeCount_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.CycleAddLikeCount, CycleAddLikeCount_Display, !CycleAddLikeCount_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + CycleAddLikeCount_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.CycleAddLikeCount) (每次随机 + -10)
                    @Html.MyNet().ValidationMessageFor(model => model.CycleAddLikeCount)
                </td>
            </tr>
            }
            @if (config.GetBoolean("CycleTimes_EditVisible"))
            {
            if (create)
            {
            Model.CycleTimes = config.GetInt("CycleTimes_Value");
            }
            var CycleTimes_Display = string.IsNullOrEmpty(config.GetString("CycleTimes_Display")) ? "总循环次数" : config.GetString("CycleTimes_Display");
            var CycleTimes_Required = config.GetBoolean("CycleTimes_Required");
            <tr>
                <th>
                    @if (CycleTimes_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.CycleTimes, CycleTimes_Display, !CycleTimes_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + CycleTimes_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.CycleTimes)
                    @Html.MyNet().ValidationMessageFor(model => model.CycleTimes)
                </td>
            </tr>
            }
            @if (config.GetBoolean("CycleCompletionTimes_EditVisible"))
            {
            if (create)
            {
            Model.CycleCompletionTimes = config.GetInt("CycleCompletionTimes_Value");
            }
            var CycleCompletionTimes_Display = string.IsNullOrEmpty(config.GetString("CycleCompletionTimes_Display")) ? "已完成次数" : config.GetString("CycleCompletionTimes_Display");
            var CycleCompletionTimes_Required = config.GetBoolean("CycleCompletionTimes_Required");
            <tr>
                <th>
                    @if (CycleCompletionTimes_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.CycleCompletionTimes, CycleCompletionTimes_Display, !CycleCompletionTimes_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + CycleCompletionTimes_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.CycleCompletionTimes)
                    @Html.MyNet().ValidationMessageFor(model => model.CycleCompletionTimes)
                </td>
            </tr>
            }
            @if (config.GetBoolean("CommentCount_EditVisible"))
            {
            if (create)
            {
            Model.CommentCount = config.GetInt("CommentCount_Value");
            }
            var CommentCount_Display = string.IsNullOrEmpty(config.GetString("CommentCount_Display")) ? "评论数" : config.GetString("CommentCount_Display");
            var CommentCount_Required = config.GetBoolean("CommentCount_Required");
            <tr>
                <th>
                    @if (CommentCount_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.CommentCount, CommentCount_Display, !CommentCount_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + CommentCount_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.CommentCount)
                    @Html.MyNet().ValidationMessageFor(model => model.ViewCount)
                </td>
            </tr>
            }
            @if (config.GetBoolean("SortIndex_EditVisible"))
            {
            if (create)
            {
            Model.SortIndex = config.GetInt("SortIndex_Value");
            }
            var SortIndex_Display = string.IsNullOrEmpty(config.GetString("SortIndex_Display")) ? "排序" : config.GetString("SortIndex_Display");
            var SortIndex_Required = config.GetBoolean("SortIndex_Required");
            <tr>
                <th>
                    @if (SortIndex_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.SortIndex, SortIndex_Display, !SortIndex_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + SortIndex_Display
                    })
                </th>
                <td>
                    @Html.MyNet().IntegerTextBoxFor(model => model.SortIndex)
                    @Html.MyNet().ValidationMessageFor(model => model.ViewCount)
                </td>
            </tr>
            }
            else
            {
            @Html.HiddenFor(model => model.SortIndex)
            }
            @if (config.GetBoolean("IsCommend_EditVisible") || config.GetBoolean("IsHot_EditVisible") || config.GetBoolean("IsTop_EditVisible"))
            {
            <tr>
                <th></th>
                <td class="checkbox">
                    @if (config.GetBoolean("IsCommend_EditVisible"))
                    {
                    if (create)
                    {
                    Model.IsCommend = config.GetBoolean("IsCommend_Value");
                    }
                    @Html.CheckBoxFor(model => model.IsCommend)
                    @Html.LabelFor(model => model.IsCommend, string.IsNullOrEmpty(config.GetString("IsCommend_Display")) ?
                    "推荐" :
                    config.GetString("IsCommend_Display"))
                    }
                    @if (config.GetBoolean("IsHot_EditVisible"))
                    {
                    if (create)
                    {
                    Model.IsHot = config.GetBoolean("IsHot_Value");
                    }
                    @Html.CheckBoxFor(model => model.IsHot)
                    @Html.LabelFor(model => model.IsHot, string.IsNullOrEmpty(config.GetString("IsHot_Display")) ?
                    "热门" :
                    config.GetString("IsHot_Display"))
                    }
                    @if (config.GetBoolean("IsTop_EditVisible"))
                    {
                    if (create)
                    {
                    Model.IsTop = config.GetBoolean("IsTop_Value");
                    }
                    @Html.CheckBoxFor(model => model.IsTop)
                    @Html.LabelFor(model => model.IsTop, string.IsNullOrEmpty(config.GetString("IsTop_Display")) ?
                    "置顶" :
                    config.GetString("IsTop_Display"))
                    }
                </td>
            </tr>
            }
            @if (config.GetBoolean("Summary_EditVisible"))
            {
            if (create)
            {
            Model.Summary = config.GetString("Summary_Value");
            }
            var Summary_Display = string.IsNullOrEmpty(config.GetString("Summary_Display")) ? "摘要" : config.GetString("Summary_Display");
            var Summary_Required = config.GetBoolean("Summary_Required");
            <tr>
                <th>
                    @if (Summary_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.Summary, Summary_Display)
                </th>
                <td>
                    @Html.MyNet().TextAreaFor(model => model.Summary, !Summary_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + Summary_Display,
                    LengthMax = 1000
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Summary)
                </td>
            </tr>
            }
            @if (config.GetBoolean("ExtField01_EditVisible"))
            {
            if (create)
            {
            Model.ExtField01 = config.GetString("ExtField01_Value");
            }
            var ExtField01_Display = string.IsNullOrEmpty(config.GetString("ExtField01_Display")) ? "扩展字段一" : config.GetString("ExtField01_Display");
            var ExtField01_Required = config.GetBoolean("ExtField01_Required");
            <tr>
                <th>
                    @if (ExtField01_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField01, ExtField01_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField01, !ExtField01_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + ExtField01_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField01)
                </td>
            </tr>
            }
            @if (config.GetBoolean("ExtField02_EditVisible"))
            {
            if (create)
            {
            Model.ExtField02 = config.GetString("ExtField02_Value");
            }
            var ExtField02_Display = string.IsNullOrEmpty(config.GetString("ExtField02_Display")) ? "扩展字段二" : config.GetString("ExtField02_Display");
            var ExtField02_Required = config.GetBoolean("ExtField02_Required");
            <tr>
                <th>
                    @if (ExtField02_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField02, ExtField02_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField02, !ExtField02_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + ExtField02_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField02)
                </td>
            </tr>
            }
            @if (config.GetBoolean("ExtField03_EditVisible"))
            {
            if (create)
            {
            Model.ExtField03 = config.GetString("ExtField03_Value");
            }
            var ExtField03_Display = string.IsNullOrEmpty(config.GetString("ExtField03_Display")) ? "扩展字段三" : config.GetString("ExtField03_Display");
            var ExtField03_Required = config.GetBoolean("ExtField03_Required");
            <tr>
                <th>
                    @if (ExtField03_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField03, ExtField03_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField03, !ExtField03_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + ExtField03_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField03)
                </td>
            </tr>
            }
            @if (config.GetBoolean("ExtField04_EditVisible"))
            {
            if (create)
            {
            Model.ExtField04 = config.GetString("ExtField04_Value");
            }
            var ExtField04_Display = string.IsNullOrEmpty(config.GetString("ExtField04_Display")) ? "扩展字段四" : config.GetString("ExtField04_Display");
            var ExtField04_Required = config.GetBoolean("ExtField04_Required");
            <tr>
                <th>
                    @if (ExtField04_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.ExtField04, ExtField04_Display)
                </th>
                <td>
                    @Html.MyNet().TextBoxFor(model => model.ExtField04, !ExtField04_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + ExtField04_Display,
                    LengthMax = 256
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.ExtField04)
                </td>
            </tr>
            }
            @if (config.GetBoolean("Text_EditVisible"))
            {
            if (create)
            {
            //Model.Text = config.GetString("Text_Value");
            }
            var Text_Display = string.IsNullOrEmpty(config.GetString("Text_Display")) ? "内容" : config.GetString("Text_Display");
            var Text_Required = config.GetBoolean("Text_Required");
            <tr>
                <th>
                    @if (Text_Required)
                    {
                    <b>*</b>
                    }
                    @Html.LabelFor(model => model.Text, string.IsNullOrEmpty(config.GetString("Text_Display")) ?
                    "内容" :
                    config.GetString("Text_Display"))
                </th>
                <td>
                    @Html.MyNet().EditorFor(model => model.Text, new EditorOptions
                    {
                    AttachmentKey = Model.Id,
                    EditorConfig = EditorConfig.Rich,
                    }, !Text_Required ? null : new ValidateOptions
                    {
                    RequiredError = "请输入" + Text_Display
                    })
                    @Html.MyNet().ValidationMessageFor(model => model.Text)
                    @*<div style="padding:5px 0;">
                    <a href="javascript:;" style="padding:5px 10px;" onclick="insertHtml(0)">插入带大数字开头的模块</a>
                    <a href="javascript:;" style="padding:5px 10px;margin-left:10px;" onclick="insertHtml(1)">插入带列表的模块</a>
                </div>*@
                </td>
            </tr>
            }
        </table>
        }
        <style>
            .form .k-textbox { width: 100%; }

            .form textarea.k-textbox { width: 100%; }

            .checkbox label { margin-right: 5px; }
        </style>
        <script>

          function insertHtml(type) {
            var editor = UE.getEditor($('.editor textarea')[0].id);
            var htmlTmp = [
              '<div class=\"cb right\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><br /><em class=\"big-num\" style=\"background-color:#fff\">1</em> 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述<div class=\"clear\"></div></div><div class=\"cb left\" style=\"padding-top:20px;\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><br /><em class=\"big-num\" style=\"background-color:#fff;padding-top:9px;\">2</em> 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述 课程描述课程描述课程描述课程描述课程描述课程描述课程描述课程描述<div class=\"clear\"><br /></div></div>'

              , '<div class=\"cb right\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><p>1、标题1</p><p>2、标题2</p><p>3、标题3</p><div class=\"clear\"></div></div><div class=\"cb left\" style=\"padding-top:20px;\"><img src=\"/App_Attachment/UnAuthorizationFolder/Common_EditorImage/84859bd4-1baa-413a-a1fb-4c27a3e71b3a.jpg?20180209192419\" title=\"2\" /><p>1、标题1</p><p>2、标题2</p><p>3、标题3</p></div></div>'
            ];
            var h = editor.getContent();
            editor.setContent(h + htmlTmp[type]);

          }

          /**/
          var isBackThis = '@isBackThis' == 'True';
          /**/

          function save() {
            var form = $("form");
            sync(form);
            if (!form.valid()) return;

            $.ajax
            ({
              url: form.attr("action"),
              data: form.serialize(),
              type: "post",
              error: disposeError,
              success: function (result) {
                if (disposeException(result)) return;
                if (isBackThis) {
                  backThis();
                } else {
                  back(true);
                }
              }
            });
          }

        </script>
